-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent million-proposal attack by introducing minimum stake req… #2805
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not that familiar with Epoch Manager, so I just skimmed over the code. Overall, looks fine to me.
/// The minimum stake required for staking is last seat price divided by this number. | ||
#[serde(default = "default_minimum_stake_divisor")] | ||
#[default(10)] | ||
pub minimum_stake_divisor: u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using Rational instead of encoding the 1/divisor
implicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's needed (at least for now) because the stake is usually a large number (due to yotcoNEAR) and for example there would very little difference if we divide by 33 or multiple by 3/100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for my side
…uirements
Fixes #2610 in two parts:
Introduce a
minimum_stake_divisor
to have a lower limit for staking transactions. If someone tries to stake with less thanlast_seat_price / minimum_stake_divisor
, the transaction will fail.Instead of copying the proposals in every block info, use an aggregator that always updates the proposal information to the last final block and at the end of an epoch, process the rest between last final block and last block of the epoch.
Test plan
neard/src/runtime
to make sure that the proposals that are now invalid are properly rejected.